package com.itbaizhan.hdfs2hbase;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @Auther: hwh
 * @Date: 2023-02-28 - 02 - 28 - 10:51
 * @Description: com.itbaizhan.hdfs2hbase
 * @version: 1.0
 */
public class Hdfs2HbaseMapper extends Mapper<LongWritable, Text,Text, IntWritable> {
    //定义输入的key
    private Text outKey = new Text();
    private IntWritable outVal = new IntWritable(1);
    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        //将读取的内容按照空格进行查菲
        String[] words = value.toString().split(" ");
        //遍历words，执行向外输出
        for(String word:words){
            //将word封装到outKey中
            outKey.set(word);
            //输出
            context.write(outKey, outVal);
        }
    }
}
